<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="java.io.*,java.util.*,java.sql.*" %>
<%@ page import="javax.servlet.http.*,javax.servlet.*" %>
<%@ page import="catcatcat.*" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>注册判断</title>
</head>
<body>
<p><b>注册用户名：</b> <%= request.getParameter("useid")%> </p>
<p><b>注册密码：</b> <%= request.getParameter("pw")%> </p>
<p><b>重复密码：</b> <%= request.getParameter("pww")%> </p>
<% 
String jiegg;
boolean isZhuCe=false;
try {
	String name=request.getParameter("useid");
	String pw=request.getParameter("pw").trim();
	String pww=request.getParameter("pww").trim();
	if(pw.equals(pww)){
		CaoZuoSql caoZuoSql=new CaoZuoSql();
		//String pwd=request.getParameter("pw").trim();
		isZhuCe=caoZuoSql.tianJia(name, pw);
		caoZuoSql.guanBi();
		if(isZhuCe){
			jiegg="注册成功！";
		}else{
			jiegg="用户名，已存在！。";
		}
	}else{
		jiegg="两次密码不对。。";
	}	
}catch (Exception e) {
	jiegg="连接数据库异常！";
}
%>
<h1>登陆结果：</h1><h3 id="jieg" style="color: red;"><%=jiegg %></h3>
<br />
<p>
<span>倒计时：</span><span id="daojishi">5</span>
</p>
<script type="text/javascript">
var tt=document.getElementById("jieg");
var tg=tt.innerHTML;
alert(tg);
onload=function(){
    setInterval(go, 1000);
};

var x=5; //利用了全局变量来执行
function go(){
	if (tg=="注册成功！") {
	    x--;
	    if(x>0){
	        document.getElementById("daojishi").innerHTML=x;  //每次设置的x的值都不一样了。
	    }else{
	        location.href='https://www.runoob.com';  // 设置你的注册页面
	    } 
	}else {
	    x--;
	    if(x>0){
	        document.getElementById("daojishi").innerHTML=x;  //每次设置的x的值都不一样了。
	    }else{
	        location.href='http://localhost:8080/catcatcat/html/login2.html';  // 设置你的注册页面
	    }
	}
} 
</script>
</body>
</html>